package com.st.lotte.util;

import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
/***************************
 * Logging Method          *  
 ***************************/

public class LogTrace {
    public static String m_FileName = "log";     
    private static FileWriter objfile = null;
    public static String m_PathName =  "/var/log/lotte/";
//    public static String m_PathName =  "/var/log/lotte/test/";
//    public static String m_PathName =  "/Users/RichardU/Documents/SweetTracker/lotte_log/";
    
    public synchronized static void TraceLog(String log){
        int i                 = 0;
        String stPath         = "";
        String stFileName     = "";
        
//        String m_PathName = "/Users/RichardU/Documents/SweetTracker/lotte_log/";  
//        String m_PathName =  "/var/log/lotte/";

        stPath     = m_PathName;
        stFileName = m_FileName;
        SimpleDateFormat formatter1 = new SimpleDateFormat ("yyyyMMdd");
        SimpleDateFormat formatter2 = new SimpleDateFormat ("HH:mm:ss");
        SimpleDateFormat formatter3 = new SimpleDateFormat ("HH");
        
        String stDate = formatter1.format(new Date());
        String stTime = formatter2.format(new Date());
        String stTimeH = formatter3.format(new Date());
        
        StringBuffer bufLogPath  = new StringBuffer();       
	    bufLogPath.append(stPath);
	    bufLogPath.append(stFileName);
	    bufLogPath.append("_");
	    bufLogPath.append(stDate+stTimeH);
	    bufLogPath.append(".log") ;
        StringBuffer bufLogMsg = new StringBuffer(); 
        bufLogMsg.append("[");
        bufLogMsg.append(stTime);
        bufLogMsg.append("] ");             
        bufLogMsg.append(log);
                     
        try{
	        objfile = new FileWriter(bufLogPath.toString(), true);
	        objfile.write(bufLogMsg.toString());
	        objfile.write("\r\n");
        }catch(IOException e){
            
        }finally{
            try{
             objfile.close();
            }catch(Exception e1){}
        }
    }
}
